<html>
<head>
<style type="text/css" media="only screen and (max-device-width: 480px)">
table {width:100%; font-family:Arial, Helvetica, sans-serif;}
a {font-family:Arial, Helvetica, sans-serif; font-size:80px; font-weight:bold;}
font {font-size:50px;}
td {width:65%;}
input {width:90; height:100}
</style>
</head>
<body>

<?php

session_start();

$_SESSION['dbhost'] = 'engr-db.engr.oregonstate.edu:3307';
$_SESSION['dbname'] = 'funkecd';
$_SESSION['dbuser'] = 'funkecd';
$_SESSION['dbpass'] = 'ktrDtj1b';
$mysql_handle = mysql_connect($_SESSION['dbhost'], $_SESSION['dbuser'], $_SESSION['dbpass'])
    or die("Error connecting to database server");

mysql_select_db($_SESSION['dbname'], $mysql_handle)
    or die("Error selecting database: $dbname");
$emid = 1;
//$query = "SELECT `emergency_status` FROM `Emergency` WHERE `emid` = $emid";
$query = "SELECT * FROM `Emergency` ORDER BY `emid` DESC;";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$emid = $row['emid'];
$status = $row['emergency_status'];

$query = "SELECT `lid` FROM `Emergency_Locations` WHERE `emid` = $emid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);

$lid = $row['lid'];

$query = "SELECT `location_name` FROM `Location_List` WHERE `lid` = $lid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);

$location = $row['location_name'];

$query = " SELECT `pid` FROM `Emergency_Patient_List` WHERE `emid` = $emid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$pid = $row['pid'];

$query = "SELECT `patient_first_name`, `patient_last_name` FROM `Patient_List` WHERE `pid` = $pid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$fname = $row['patient_first_name'];
$lname = $row['patient_last_name'];

$query = "SELECT  `reason_for_cs` FROM  `Patient_Medical_Data` WHERE pid = $pid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$reason = $row['reason_for_cs'];
$tag = "<tr><td align = \"left\">";
$td = "<td align = \"left\">";
$bodyText = "
<font face= \"Arial, Helvetica, sans-serif\" size = \"6\">
Summons Information<br>

<table bordercolor=blue><tr><td<table frame=\"border\" width=\"300\" height=\"180\">
$tag  Patient: $td <b>$fname $lname</b>
$tag  Status: $td <b>$status</b>
$tag  Reason for CS: $td <b>$reason</b>
$tag  Assembly Location: $td <b>$location</b>
</table></table>";
echo $bodyText;
mysql_close($mysql_handle);

?>
